import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'SimHei'
x1= [2018,2019,2020,2021]
nanjing = [843.62,850,931.46,942.34]
wuhan = [1108.1,1121.2,1232.65,1364.89]
guangzhou=[1490.44,1530.59,1867.66,1881.06]
shenzhen = [1666.12,1710.4,1763.38,1768.16]
beijing = [2154.2,2153.6,2189.3,2188.6]
shanghai = [2423.78, 2481, 2428.14, 2489.43]
plt.plot(x1,shanghai,'p--',label='上海')
plt.plot(x1,beijing,'x--',label='北京')
plt.plot(x1,guangzhou,'d--',label='广州')
plt.plot(x1,shenzhen,'h--',label='深圳')
plt.plot(x1,wuhan,'s--',label='武汉')
plt.plot(x1,nanjing,'D--',label='南京')
plt.xlabel('年份')
plt.ylabel('万人')
plt.title('六大城市人口走势')
plt.legend(bbox_to_anchor=(1, 0), loc=3, borderaxespad=0)
plt.show()
